package cn.zzuisa.controller;


import cn.zzuisa.entity.Config;
import cn.zzuisa.service.ConfigService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.zzuisa.base.R;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author frank
 * @since 2019-05-09
 */
@Api(tags = "配置管理")
@RestController
@RequestMapping("/config")
public class ConfigController {

    @Autowired
    ConfigService configService;

    @GetMapping("/list")
    public R<List<Config>> list() {
        List<Config> list = configService.list(new QueryWrapper<Config>());
        return R.ok(list);
    }

    @PutMapping("/new")
    public R<Config> update(@RequestBody  Config config) {
        configService.updateById(config);
        return R.ok(config);
    }
    @GetMapping("/listIndexImg")
    public R<List<Config>> listIndexImg() {
        List<Config> list = configService.list(new QueryWrapper<Config>().like("config_name","index%"));
        return R.ok(list);
    }

}
